home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / qbnws24j.lzh / WINDOWER.ASM < prev    next >
Assembly Source File  |  1991-07-15  |  33KB  |  569 lines

  1. ; WINDOWER.ASM  This is a window management system, intended to be linked
  2. ;               with programs written in Microsoft high-level languages.
  3. ;               It can be used to draw and restore windows in a variety of
  4. ;               styles and colours. Windows can be zoomed onto the screen
  5. ;               and may have shadows to the left or right if required.  
  6. ;
  7. ;   Author:     Christy Gemmell    
  8. ;   For:        Assembly-Language ToolBox for QuickBASIC
  9. ;   Version:    5.00
  10. ;   Date:       17/6/1991
  11. ;
  12. ;   Compatible with QuickBASIC 4.x, Extended QuickBASIC and BASIC 7
  13. ;   Assembled with MicroSoft Macro Assembler, MASM version 5.1
  14. ;
  15. ;   Exploding and imploding windows implemented 17/6/91
  16. ;
  17. ;┌────────────────────────────────────────────────────────────────────────┐
  18. ;│      Global symbols and procedures.                                    │
  19. ;└────────────────────────────────────────────────────────────────────────┘
  20. ;
  21.                 .model  medium
  22.  
  23.                 extrn   Delay:proc
  24.                 extrn   Explode:proc
  25.                 extrn   ScreenAddress:proc
  26.                 extrn   ScreenCopy:proc
  27.                 extrn   ScreenWrite:proc
  28.                 extrn   VideoType:proc 
  29.                 extrn   WriteByte:proc
  30.  
  31.                 public  PopUp, ShutUp
  32.  
  33.                 .code
  34.  
  35. ;┌────────────────────────────────────────────────────────────────────────┐
  36. ;│      Data Division.                                                    │
  37. ;└────────────────────────────────────────────────────────────────────────┘
  38. ;
  39. Signature       db      ' WINDOW MANAGER By Christy Gemmell '
  40.  
  41. Ulc             label   word                    ; Upper left co-ordinate
  42. TlRow           db      ?                       ; Top left screen row
  43. TlCol           db      ?                       ; Top left screen column
  44. Lrc             label   word                    ; Lower right co-ordinate
  45. BrCol           db      ?                       ; Right column of window
  46. BrRow           db      ?                       ; Bottom row of window
  47. Area            label   word
  48. Breadth         db      ?                       ; Window width (inc shadow)
  49. Height          db      ?                       ; Window Height (inc shadow)
  50. ToDo            label   word
  51. Cols2do         db      ?                       ; Columns to restore
  52. Rows2do         db      ?                       ; Rows to restore
  53. Rows            db      ?                       ; Screen length in rows
  54. Columns         db      ?                       ; Screen width in columns
  55. Increment       dw      ?                       ; Interval between rows
  56. BuffPtr         dw      ?                       ; Pointer to current buffer
  57. BuffTop         dw      ?                       ; Offset of first buffer row
  58. BuffEnd         dw      ?                       ; Offset of last buffer row
  59. WinTop          dw      ?                       ; Offset of first screen row
  60. WinEnd          dw      ?                       ; Offset of last screen row
  61.  
  62. TopLeft         label   byte
  63.                 db      ' ┌╔╒╓╤╦┬╥'             ; TL Corner characters
  64. TopRight        label   byte
  65.                 db      ' ┐╗╕╖╤╦┬╥'             ; TR Corner characters
  66. BotLeft         label   byte
  67.                 db      ' └╚╘╙╘╚└╙'             ; BL Corner characters
  68. BotRight        label   byte
  69.                 db      ' ┘╝╛╜╛╝┘╜'             ; BR Corner characters
  70. Vertical        label   byte
  71.                 db      ' │║│║│║│║'             ; Vertical characters
  72. Horizontal      label   byte
  73.                 db      ' ─══─══──'             ; Horizontal characters
  74.  
  75. Buffer          label   byte                    ; Start of screen buffer
  76.                 db      4000h dup(0)
  77. BufferTop       dw      0                       ; End of screen Buffer
  78.  
  79. ;┌────────────────────────────────────────────────────────────────────────┐
  80. ;│      POPUP | Save a screen rectangle and replace it with a window.     │
  81. ;└────────────────────────────────────────────────────────────────────────┘
  82. ;
  83. PopUp           proc    far
  84.                 push    bp                      ; Save Base pointer
  85.                 mov     bp,sp                   ; Establish stack frame
  86.                 push    ds                      ; Preserve segment
  87.                 push    es                      ;    registers and
  88.                 push    di                      ;      index
  89.                 push    si                      ;        pointers
  90.                 call    VideoType               ; Get video parameters
  91.                 push    cs                      ; Align Code and
  92.                 pop     ds                      ;    Data segments
  93.                 mov     Rows,bl                 ; Store screen height
  94.                 mov     Columns,ah              ; Store screen width
  95.                 mov     al,ah                   ; Transfer number of
  96.                 xor     ah,ah                   ;    columns to AX
  97.                 shl     ax,1                    ;      and convert
  98.                 mov     Increment,ax            ;        to bytes
  99.                 mov     al,[bp+20]              ; Get top-left row
  100.                 dec     al                      ; Make it base zero
  101.                 cmp     al,0                    ; Check for
  102.                 jae     Pop_01                  ;    legal
  103.                 xor     al,al                   ;      values
  104. Pop_01:
  105.                 mov     TlRow,al                ; Save top-left row
  106.                 mov     al,[bp+18]              ; Get top-left column
  107.                 dec     al                      ; Make it base zero
  108.                 cmp     al,0                    ; Check for
  109.                 ja      Pop_02                  ;    legal
  110.                 mov     al,1                    ;      values
  111. Pop_02:
  112.                 mov     TlCol,al                ; Store top-left column
  113.                 mov     al,[bp+16]              ; Get window height
  114.                 cmp     al,2                    ; Check for
  115.                 ja      Pop_03                  ;    legal
  116.                 mov     al,3                    ;      values
  117. Pop_03:
  118.                 mov     [bp+16],al              ; Store window height
  119.                 mov     al,[bp+14]              ; Get window width
  120.                 cmp     al,2                    ; Check for
  121.                 ja      Pop_04                  ;    legal
  122.                 mov     al,3                    ;      values
  123. Pop_04:
  124.                 mov     [bp+14],al              ; Store window width
  125.                 mov     al,TlRow                ; Get start row
  126.                 mov     ah,[bp+16]              ; Get number of rows
  127.                 add     al,ah                   ; Add 'em together
  128.                 cmp     al,Rows                 ; Out of bounds?
  129.                 jb      Pop_05                  ; No, carry on
  130.                 jmp     Pop_38                  ; Else abort
  131. Pop_05:
  132.                 dec     al                      ; Store bottom
  133.                 mov     BrRow,al                ;    row number
  134.                 mov     al,TlCol                ; Get start column
  135.                 mov     ah,[bp+14]              ; Get number of columns
  136.                 add     al,ah                   ; Add 'em together
  137.                 cmp     al,Columns              ; Out of bounds?
  138.                 jb      Pop_06                  ; No, carry on
  139.                 jmp     Pop_38                  ; Else abort
  140. Pop_06:
  141.                 dec     al                      ; Store rightmost
  142.                 mov     BrCol,al                ;    column number
  143.                 mov     al,[bp+10]              ; Get required border type
  144.                 cmp     al,0                    ; Check
  145.                 jb      Pop_07                  ;    for
  146.                 cmp     al,8                    ;      legal
  147.                 ja      Pop_07                  ;        values
  148.                 jmp     short Pop_08
  149. Pop_07:
  150.                 mov     byte ptr [bp+10],1      ; Set default (single line)
  151. Pop_08:
  152.                 mov     ax,[bp+8]               ; See if shadow is required
  153.                 cmp     al,0                    ; Check
  154.                 jb      Pop_09                  ;    for
  155.                 cmp     al,4                    ;      legal
  156.                 ja      Pop_09                  ;        values
  157.                 jmp     short Pop_10
  158. Pop_09:
  159.                 mov     byte ptr [bp+8],0       ; Set default (no shadow)
  160. Pop_10:
  161.                 cmp     word ptr [bp+6],0       ; Check for
  162.                 jge     Pop_11                  ;    legal
  163.                 mov     word ptr [bp+6],20      ;      values
  164. Pop_11:
  165.                 mov     ax,1                    ; Initialise                   
  166.                 push    ax                      ;    millisecond 
  167.                 call    Delay                   ;      delay routine
  168.                 xor     ax,ax                   ; Get number of rows
  169.                 mov     al,[bp+16]              ;    into AX
  170.                 xor     bx,bx                   ; Get number of columns
  171.                 mov     bl,[bp+14]              ;    into BX
  172.                 cmp     byte ptr [bp+8],0       ; Shadow required?
  173.                 jz      Pop_12                  ; No, skip next bit
  174.                 inc     al                      ; Add a row
  175.                 inc     bl                      ;    and a column
  176. Pop_12:
  177.                 mov     Height,al               ; Store adjusted height
  178.                 mov     Breadth,bl              ; Store adjusted width
  179.                 mul     bl                      ; Find area
  180.                 shl     ax,1                    ;    in bytes
  181.                 mov     cx,ax                   ; Transfer to CX
  182.                 mov     si,offset Buffer        ; Start of screen stack
  183. Pop_13:
  184.                 cmp     word ptr [si],0         ; Is anything there?
  185.                 jz      Pop_14                  ; No, must be free space
  186.                 mov     si,[si]                 ; Point to next block
  187.                 jmp     Pop_13                  ;    and try again
  188. Pop_14:
  189.                 mov     ax,si                   ; Point AX to entry
  190.                 add     ax,6                    ; Allow for pointers
  191.                 add     ax,cx                   ;    and area to be saved
  192.                 mov     dx,offset BufferTop     ; Point DX to end of stack
  193.                 cmp     ax,dx                   ; Enough space left?
  194.                 jb      Pop_15                  ; Yes, Carry on
  195.                 jmp     Pop_38                  ; Otherwise abort
  196. Pop_15:
  197.                 mov     [si],ax                 ; Set pointer to next block
  198.                 mov     ax,Ulc                  ; Get row-column co-ordinates
  199.                 call    ScreenAddress           ; Convert to memory address
  200.                 mov     WinTop,di               ; Save it for later
  201.                 test    byte ptr [bp+8],1       ; Left shadow?
  202.                 jz      Pop_16                  ; No, skip next bit
  203.                 dec     di                      ; One column
  204.                 dec     di                      ;    to the left
  205. Pop_16:
  206.                 inc     si                      ; Bump buffer
  207.                 inc     si                      ;    pointer
  208.                 mov     [si],di                 ; Store it in buffer
  209.                 inc     si                      ; Bump buffer
  210.                 inc     si                      ;    pointer
  211.                 mov     ax,Area                 ; Get panel Area
  212.                 mov     [si],ax                 ; Store them in the buffer
  213.                 inc     si                      ; Bump pointer to
  214.                 inc     si                      ;    screen storage block
  215.                 xor     cx,cx                   ; Get number of rows
  216.                 mov     cl,ah                   ;    in CX
  217.                 xchg    di,si                   ; Swap pointers
  218.                 push    ds                      ; Point DS to
  219.                 push    es                      ;    video segment
  220.                 pop     ds                      ;      and ES to
  221.                 pop     es                      ;        local data
  222. Pop_17:          
  223.                 push    cx                      ; Save row count
  224.                 push    si                      ; Save screen pointer
  225.                 mov     cl,cs:Breadth           ; Set column count
  226. Pop_18:
  227.                 call    ScreenCopy              ; Copy word from screen
  228.                 loop    Pop_18                  ; For length of row
  229.                 pop     si                      ; Bump pointer
  230.                 add     si,cs:Increment         ;    to next row
  231.                 pop     cx                      ; Recover row count
  232.                 loop    Pop_17                  ; For each row
  233.                 push    es                      ; Realign Code and
  234.                 pop     ds                      ;    Data segments
  235.                 xor     ah,ah                   ; Get all parameters in AX
  236.                 mov     al,TlRow                ; Get upper-left row
  237.                 inc     al                      ; Must use BASIC numbering
  238.                 push    ax                      ; Pass the argument
  239.                 mov     al,TlCol                ; Get upper-left column
  240.                 inc     al                      ; Must use BASIC numbering
  241.                 push    ax                      ; Pass the argument
  242.                 mov     al,BrRow                ; Get lower-right row
  243.                 inc     al                      ; Must use BASIC numbering
  244.                 push    ax                      ; Pass the argument
  245.                 mov     al,BrCol                ; Get lower-right column
  246.                 inc     al                      ; Must use BASIC numbering
  247.                 push    ax                      ; Pass the argument
  248.                 push    [bp+12]                 ; Pass display attribute
  249.                 push    [bp+6]                  ; Pass speed value
  250.                 call    Explode                 ; Display the window
  251.                 mov     ax,Ulc                  ; Get row/column co-ordinate
  252.                 call    ScreenAddress           ; Convert to memory address
  253.                 cmp     byte ptr [bp+10],0      ; Border required?
  254.                 ja      Pop_19                  ; Yes, draw it
  255.                 jmp     Pop_23                  ; Else check for shadow
  256. Pop_19:
  257.                 xor     bx,bx                   ; Border type
  258.                 mov     bl,[bp+10]              ;    to BX
  259.                 mov     ah,[bp+12]              ; Attribute to AH
  260.                 push    di                      ; Save screen offset
  261.                 mov     al,TopLeft[bx]          ; Border character to AL
  262.                 call    ScreenWrite             ; Send it to the screen
  263.                 mov     al,Horizontal[bx]       ; Border character to AL
  264.                 xor     cx,cx                   ; Window width
  265.                 mov     cl,[bp+14]              ;    to CX
  266.                 dec     cl                      ; Subtract
  267.                 dec     cl                      ;    corners
  268. Pop_20:
  269.                 call    ScreenWrite             ; Send it to the screen
  270.                 loop    Pop_20
  271.                 mov     al,TopRight[bx]         ; Border character to AL
  272.                 call    ScreenWrite             ; Send it to the screen
  273.                 pop     di                      ; Recover offset
  274.                 add     di,Increment            ; Bump to next row
  275.                 mov     al,Vertical[bx]         ; Border character to AL
  276.                 mov     cl,[bp+16]              ; Window height to CX
  277.                 dec     cl                      ; Subtract top and
  278.                 dec     cl                      ;    bottom rows
  279. Pop_21:
  280.                 push    cx                      ; Save counter
  281.                 push    di                      ; Save screen pointer
  282.                 call    ScreenWrite             ; Left border
  283.                 mov     cl,[bp+14]              ; Get window width
  284.                 dec     cl                      ; Point
  285.                 dec     cl                      ;    to      
  286.                 shl     cx,1                    ;      rightmost
  287.                 add     di,cx                   ;        column
  288.                 call    ScreenWrite             ; Right border
  289.                 pop     di                      ; Recover screen pointer
  290.                 add     di,Increment            ; Bump to next row
  291.                 pop     cx                      ; Recover row count
  292.                 loop    Pop_21                  ; For each row
  293.                 mov     al,BotLeft[bx]          ; Border character to AL
  294.                 call    ScreenWrite             ; Send it to the screen
  295.                 mov     al,Horizontal[bx]       ; Border character to AL
  296.                 mov     cl,[bp+14]              ; Get window width
  297.                 dec     cl                      ; Subtract
  298.                 dec     cl                      ;    corners
  299. Pop_22:
  300.                 call    ScreenWrite             ; Send it to the screen
  301.                 loop    Pop_22
  302.                 mov     al,BotRight[bx]         ; Border character to AL
  303.                 call    ScreenWrite             ; Send it to the screen
  304. Pop_23:
  305.                 cmp     byte ptr [bp+8],0       ; Shadow required?
  306.                 ja      Pop_24                  ; Yes, handle it
  307.                 jmp     Pop_37                  ; Else wrap everything up
  308. Pop_24:
  309.                 mov     di,WinTop               ; Back to top-left corner
  310.                 add     di,Increment            ;    start at next row down
  311.                 xor     cx,cx                   ; Get window width
  312.                 mov     cl,[bp+14]              ;    into CX
  313.                 shl     cx,1                    ; Include attribute bytes
  314.                 cmp     byte ptr [bp+8],2       ; Solid shadow?
  315.                 ja      Pop_30                  ; No, make it transparant
  316.                 cmp     byte ptr [bp+8],1       ; Left shadow?
  317.                 jne     Pop_25                  ; No, must be right
  318.                 dec     di                      ; Left one
  319.                 dec     di                      ;    column
  320.                 jmp     short Pop_26            ; Get to work
  321. Pop_25:
  322.                 add     di,cx                   ; Offset past right-hand edge
  323. Pop_26:
  324.                 mov     ax,720h                 ; Space on black background
  325.                 push    cx                      ; Save width for now
  326.                 mov     cl,[bp+16]              ; Rows to shadow
  327. Pop_27:
  328.                 call    ScreenWrite             ; Send it to the screen
  329.                 add     di,Increment            ; Bump to
  330.                 dec     di                      ;    next
  331.                 dec     di                      ;      row 
  332.                 loop    Pop_27                  ; For height of window
  333.                 pop     cx                      ; Recover window width
  334.                 sub     di,Increment            ; Back up one row
  335.                 cmp     byte ptr [bp+8],1       ; Left shadow?
  336.                 je      Pop_28                  ; No, must be right
  337.                 sub     di,cx                   ; Jump back to start of row
  338.                 inc     di                      ; Begin one column
  339.                 inc     di                      ;    in from left
  340. Pop_28:
  341.                 shr     cx,1                    ; Convert width to columns
  342. Pop_29:
  343.                 call    ScreenWrite             ; Put black shadow
  344.                 loop    Pop_29                  ;    under the bottom row
  345.                 jmp     short Pop_37            ; Branch to the exit
  346. Pop_30:
  347.                 cmp     byte ptr [bp+8],3       ; Left shadow?
  348.                 jne     Pop_31                  ; No, must be right
  349.                 dec     di                      ; Left one
  350.                 dec     di                      ;    column
  351.                 jmp     short Pop_32            ; Get to work
  352. Pop_31:
  353.                 add     di,cx                   ; Offset past right-hand edge
  354. Pop_32:
  355.                 inc     di                      ; Bump to attribute byte
  356.                 mov     al,8                    ; Dark grey background
  357.                 push    cx                      ; Save width for now
  358.                 mov     cl,[bp+16]              ; Rows to shadow
  359. Pop_33:
  360.                 call    WriteByte               ; Set display attribute
  361.                 add     di,Increment            ; Bump to
  362.                 dec     di                      ;    next row
  363.                 loop    Pop_33                  ; For height of window
  364.                 pop     cx                      ; Recover window width
  365.                 sub     di,Increment            ; Back up
  366.                 inc     di                      ;    one row
  367.                 cmp     byte ptr [bp+8],3       ; Left shadow?
  368.                 jne     Pop_34                  ; No, must be right
  369.                 dec     di                      ; Back up one column
  370.                 jmp     short Pop_35            ; Start on bottom row
  371. Pop_34:
  372.                 sub     di,cx                   ; Jump back to the
  373.                 inc     di                      ;    beginning of the row
  374. Pop_35:
  375.                 shr     cx,1                    ; Convert width to columns
  376. Pop_36:
  377.                 call    WriteByte               ; Set display attribute
  378.                 inc     di                      ; Bump past character byte    
  379.                 loop    Pop_36                  ; For width of window
  380. Pop_37:
  381.                 xor     ax,ax                   ; Report no error
  382. Pop_38:
  383.                 pop     si                      ; Clean up the stack
  384.                 pop     di
  385.                 pop     es
  386.                 pop     ds
  387.                 pop     bp
  388.                 ret     16                      ; Return to caller
  389. PopUp           endp
  390.  
  391. ;┌────────────────────────────────────────────────────────────────────────┐
  392. ;│      Close the last window opened by restoring the screen under it.    │
  393. ;└────────────────────────────────────────────────────────────────────────┘
  394. ;
  395. ;   If a delay is specified, this routine produces the effect of imploding
  396. ;   the storage buffer contents onto the screen, making the window appear
  397. ;   to vanish into a point source.
  398. ;
  399. ShutUp          proc    far
  400.                 push    bp                      ; Save base pointer
  401.                 mov     bp,sp                   ; Establish stack frame
  402.                 push    ds                      ; Save segment
  403.                 push    es                      ;    registers and
  404.                 push    di                      ;      index
  405.                 push    si                      ;        pointers
  406.                 push    cs                      ; Align code and
  407.                 pop     ds                      ;    data segments
  408.                 cld                             ; Clear direction forward
  409.                 call    VideoType               ; Get video parameters
  410.                 mov     al,ah                   ; Transfer number of
  411.                 xor     ah,ah                   ;    columns to AX
  412.                 shl     ax,1                    ;      and convert
  413.                 mov     Increment,ax            ;        to bytes
  414.                 mov     si,offset Buffer        ; DS:SI==> screen buffer
  415.                 xor     ax,ax                   ; Initialise
  416.                 push    ax                      ;    back pointer
  417. Shut_01:
  418.                 cmp     word ptr [si],0         ; Is anything there?
  419.                 jz      Shut_02                 ; No, we're at the end
  420.                 pop     ax                      ; Retrieve pointer
  421.                 push    si                      ; Save present pointer
  422.                 mov     si,[si]                 ; Point to next block
  423.                 jmp     Shut_01                 ; Keep searching
  424. Shut_02:
  425.                 pop     si                      ; Retrieve last pointer
  426.                 cmp     si,0                    ; Was there anything?
  427.                 jnz     Shut_03                 ; Yes, proceed
  428.                 mov     ax,1                    ; Else set Errorlevel
  429.                 jmp     Shut_14                 ;    and abort
  430. Shut_03:
  431.                 mov     BuffPtr,si              ; Save buffer pointer
  432.                 inc     si                      ; Bump to
  433.                 inc     si                      ;    next entry
  434.                 mov     di,[si]                 ; ES:DI==> screen location
  435.                 mov     WinTop,di               ; Save screen offset
  436.                 inc     si                      ; Bump to
  437.                 inc     si                      ;    next entry
  438.                 mov     ax,[si]                 ; Get panel dimensions
  439.                 mov     Area,ax                 ; Store them
  440.                 mov     ToDo,ax                 ;    for later
  441.                 inc     si                      ; Bump to screen
  442.                 inc     si                      ;    storage block
  443.                 mov     BuffTop,si              ; Save buffer pointer
  444.                 xor     bx,bx                   ; AX has window width
  445.                 xchg    bl,ah                   ; BX has window height
  446.                 dec     bl                      ;    less one row
  447.                 shl     bx,1                    ; Convert to bytes
  448.                 mul     bx                      ; Calculate offset
  449.                 add     ax,si                   ;    of the last row
  450.                 mov     BuffEnd,ax              ; Save this as well
  451.                 mov     ax,Increment            ; Multiply screen width
  452.                 mov     bl,Height               ;    by window height
  453.                 dec     bl                      ;      less one row
  454.                 mul     bx                      ; Result is relative offset
  455.                 add     ax,di                   ; Now convert it to the
  456.                 mov     WinEnd,ax               ;    absolute screen offset
  457.                 xor     ax,ax                   ; Get video segment
  458.                 call    ScreenAddress           ;    and CRT status port
  459.                 cmp     word ptr [bp+6],0       ; Check for
  460.                 jge     Shut_04                 ;    legal delay
  461.                 mov     word ptr [bp+6],20      ;      values
  462. Shut_04:
  463.                 xor     cx,cx                   ; Clear counter
  464.                 mov     si,BuffTop              ; DS:SI==> first buffer row
  465.                 mov     di,WinTop               ; ES:DI==> first screen row
  466.                 mov     cl,Cols2do              ; Number of words to copy
  467. Shut_05:
  468.                 call    ScreenCopy              ; Send word to the screen
  469.                 loop    Shut_05                 ; For length of row
  470.                 dec     Rows2do                 ; All rows done?
  471.                 jnz     Shut_06                 ; No, carry on
  472.                 jmp     Shut_13                 ; Otherwise depart
  473. Shut_06:
  474.                 mov     si,BuffEnd              ; DS:SI==> last buffer row
  475.                 mov     di,WinEnd               ; ES:DI==> last screen row
  476.                 mov     cl,Cols2do              ; Number of words to copy
  477. Shut_07:
  478.                 call    ScreenCopy              ; Send word to the screen
  479.                 loop    Shut_07                 ; For length of row
  480.                 dec     Rows2do                 ; All rows done?
  481.                 jnz     Shut_08                 ; No, carry on
  482.                 jmp     Shut_13                 ; Otherwise depart
  483. Shut_08:
  484.                 xor     ax,ax                   ; Clear AX
  485.                 mov     si,BuffTop              ; Reset
  486.                 mov     al,Breadth              ;    pointer
  487.                 shl     al,1                    ;      to first
  488.                 add     si,ax                   ;        buffer
  489.                 mov     BuffTop,si              ;          row
  490.                 mov     di,WinTop               ; Do the same
  491.                 add     di,Increment            ;   for the first
  492.                 mov     WinTop,di               ;     screen row
  493.                 mov     ax,BuffEnd              ; Reset
  494.                 mov     cl,Breadth              ;    pointer
  495.                 shl     cl,1                    ;      to last
  496.                 sub     ax,cx                   ;        buffer
  497.                 mov     BuffEnd,ax              ;          row
  498.                 mov     ax,WinEnd               ; Do the same
  499.                 sub     ax,Increment            ;   for the last
  500.                 mov     WinEnd,ax               ;     screen row
  501. Shut_09:                
  502.                 cmp     si,BuffEnd              ; End of buffer?
  503.                 ja      Shut_10                 ; Yes, see if we've finished
  504.                 call    ScreenCopy              ; Send word to the screen
  505.                 xor     ax,ax                   ; Clear AX again
  506.                 mov     al,Breadth              ; Keep
  507.                 dec     al                      ;    doing
  508.                 shl     al,1                    ;      it
  509.                 add     si,ax                   ;        all
  510.                 add     di,Increment            ;          down
  511.                 dec     di                      ;            the
  512.                 dec     di                      ;              left
  513.                 jmp     short Shut_09           ;                side
  514. Shut_10:
  515.                 dec     Cols2do                 ; All columns done?
  516.                 jz      Shut_13                 ; If so, depart
  517.                 mov     al,Cols2do              ; How far to the
  518.                 shl     al,1                    ;    end of the row?
  519.                 mov     si,BuffTop              ; Point SI to
  520.                 add     si,ax                   ;    buffer data
  521.                 mov     di,WinTop               ; Point DI to
  522.                 add     di,ax                   ;    screen offset
  523. Shut_11:
  524.                 call    ScreenCopy              ; Send word to the screen
  525.                 cmp     si,BuffEnd              ; End of buffer?
  526.                 ja      Shut_12                 ; Yes, see if we're finished
  527.                 xor     ax,ax                   ; Clear AX again
  528.                 mov     al,Breadth              ; Keep
  529.                 dec     al                      ;    doing
  530.                 shl     al,1                    ;      it
  531.                 add     si,ax                   ;        all
  532.                 add     di,Increment            ;          down
  533.                 dec     di                      ;            the
  534.                 dec     di                      ;              right
  535.                 jmp     short Shut_11           ;                side
  536. Shut_12:
  537.                 dec     Cols2do                 ; All columns done?
  538.                 jz      Shut_13                 ; If so, depart
  539.                 add     BuffTop,2               ; Each subsequent
  540.                 add     BuffEnd,2               ;    row starts
  541.                 add     WinTop,2                ;      another word
  542.                 add     WinEnd,2                ;        further in
  543.                 push    [bp+6]                  ; Pass speed value
  544.                 call    Delay                   ; Pause awhile
  545.                 jmp     Shut_04                 ; Then do it all again
  546. Shut_13:
  547.                 mov     di,BuffPtr              ; Recover buffer pointer
  548.                 mov     cx,[di]                 ; Pointer to next block
  549.                 sub     cx,di                   ; Calculate length of block
  550.                 inc     cx
  551.                 push    ds                      ; Point ES to Data Segment
  552.                 pop     es
  553.                 xor     ax,ax                   ; Clear AX
  554.                 rep     stosb                   ; Zero restored block
  555. Shut_14:
  556.                 pop     si                      ; Clean up the stack
  557.                 pop     di
  558.                 pop     es
  559.                 pop     ds
  560.                 pop     bp
  561.                 ret     2                       ; Return to caller
  562. ShutUp          endp
  563.  
  564.                 end
  565.  
  566. ;┌────────────────────────────────────────────────────────────────────────┐
  567. ;│      (c) 1988,1991  By Christy Gemmell and Singular SoftWare.          │
  568. ;└────────────────────────────────────────────────────────────────────────┘
  569.